function updateXY(activity) {
    var transition = context.getTransitionOfActivity(activity);
    var startTransitionList = transition.startActivityList;
    // 更新当前节点为起始节点的所有路由的坐标
    for (var i = 0; i < startTransitionList.length; i++) {
        updateTransitionXY(startTransitionList[i], "start");
    }
    
    var endTransitionList = transition.endActivityList;
    // 更新当前节点为结束节点的所有路由的坐标
    for (var i = 0; i < endTransitionList.length; i++) {
        updateTransitionXY(endTransitionList[i], "end");
    }
};

function updateTransitionXY(transition, flag) {
    if (transition.view.attrs.path.length == 2) {// 无折点路由坐标计算
        var startHotPoint = transition.startActivity.hotPoint;
        var sx = startHotPoint.topMiddle.attrs.x;
        var sy = startHotPoint.middleLeft.attrs.y;
        
        var endHotPoint = transition.endActivity.hotPoint;
        var ex = endHotPoint.topMiddle.attrs.x;
        var ey = endHotPoint.middleLeft.attrs.y;
        
        var result = compareCoordinate({
            x: sx,
            y: sy
        }, {
            x: ex,
            y: ey
        }, transition);
        transition.updateStartXY(result.start.x, result.start.y);
        transition.updateEndXY(result.end.x, result.end.y);
    } else {// 有折点计算路由坐标
        if (flag == "start") {// 修改起始节点坐标
            var startHotPoint = transition.startActivity.hotPoint;
            var sx = startHotPoint.topMiddle.attrs.x;
            var sy = startHotPoint.middleLeft.attrs.y;
            
            var ex = transition.view.attrs.path[1][1];
            var ey = transition.view.attrs.path[1][2];
            
            var result = compareCoordinate({
                x: sx,
                y: sy
            }, {
                x: ex,
                y: ey
            }, transition);
            transition.updateStartXY(result.start.x, result.start.y);
        } else if (flag == "end") {// 修改结束节点坐标
            var sx = transition.view.attrs.path[transition.view.attrs.path.length - 2][1];
            var sy = transition.view.attrs.path[transition.view.attrs.path.length - 2][2];
            
            var endHotPoint = transition.endActivity.hotPoint;
            var ex = endHotPoint.topMiddle.attrs.x;
            var ey = endHotPoint.middleLeft.attrs.y;
            
            var result = compareCoordinate({
                x: sx,
                y: sy
            }, {
                x: ex,
                y: ey
            }, transition);
            transition.updateEndXY(result.end.x, result.end.y);
        }
    }
};

function compareCoordinate(start, end, transition) {
	var result = {}, sx = start.x, sy = start.y, ex = end.x, ey = end.y;
	if (Math.abs((Math.abs(end.x) - Math.abs(start.x))) > Math.abs((Math.abs(end.y) - Math.abs(start.y)))) {
		if (end.x > start.x) {// 右
			// 路由起始节点
			if (transition.startActivity) {
				var activityHotPoint = transition.startActivity.hotPoint;
				sx = activityHotPoint.middleRight.attrs.x;
				sy = activityHotPoint.middleRight.attrs.y;
			}
			// 路由结束节点
			if (transition.endActivity) {
				var activityHotPoint = transition.endActivity.hotPoint;
				ex = activityHotPoint.middleLeft.attrs.x;
				ey = activityHotPoint.middleLeft.attrs.y;
			}
		} else {// 左
			// 路由起始节点
			if (transition.startActivity) {
				var activityHotPoint = transition.startActivity.hotPoint;
				sx = activityHotPoint.middleLeft.attrs.x;
				sy = activityHotPoint.middleLeft.attrs.y;
			}
			// 路由结束节点
			if (transition.endActivity) {
				var activityHotPoint = transition.endActivity.hotPoint;
				ex = activityHotPoint.middleRight.attrs.x;
				ey = activityHotPoint.middleRight.attrs.y;
			}
		}
	} else {
		if (end.y > start.y) {// 下
			// 路由起始节点
			if (transition.startActivity) {
				var activityHotPoint = transition.startActivity.hotPoint;
				sx = activityHotPoint.bottomMiddle.attrs.x;
				sy = activityHotPoint.bottomMiddle.attrs.y;
			}
			// 路由结束节点
			if (transition.endActivity) {
				var activityHotPoint = transition.endActivity.hotPoint;
				ex = activityHotPoint.topMiddle.attrs.x;
				ey = activityHotPoint.topMiddle.attrs.y;
			}
		} else {// 上
			// 路由起始节点
			if (transition.startActivity) {
				var activityHotPoint = transition.startActivity.hotPoint;
				sx = activityHotPoint.topMiddle.attrs.x;
				sy = activityHotPoint.topMiddle.attrs.y;
			}
			// 路由结束节点
			if (transition.endActivity) {
				var activityHotPoint = transition.endActivity.hotPoint;
				ex = activityHotPoint.bottomMiddle.attrs.x;
				ey = activityHotPoint.bottomMiddle.attrs.y;
			}
		}
	}
	result.start = {x: sx, y: sy};
	result.end = {x: ex, y: ey};
	return result;
}